# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=machinae
pkgver=197.9ef3e6c
pkgrel=4
groups=('blackarch' 'blackarch-recon')
pkgdesc='A tool for collecting intelligence from public sites/feeds about various security-related pieces of data.'
arch=('any')
url='https://github.com/HurricaneLabs/machinae'
license=('MIT')
depends=('python' 'python-dateutil' 'python-requests' 'python-yaml'
         'python-magic' 'python-stopit' 'python-feedparser' 'python-ipwhois'
         'python-pytz' 'python-beautifulsoup4' 'python-tzlocal'
         'python-filemagic' 'python-relatime' 'python-html5lib' 'python-defang'
         'python-dnspython')
makedepends=('git' 'python-setuptools')
source=("git+https://github.com/HurricaneLabs/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  # psst, tmp fix...
  sed -i 's/import machinae//g' setup.py
  sed -i 's|VERSION = machinae.__version__|VERSION = "1.4.5"|' setup.py
  sed -i 's|ipwhois<0.11|ipwhois|' setup.py
  sed -i 's|dnspython3|dnspython|' setup.py
  sed -i 's|dnspython3|dnspython|' requirements.txt
}

package() {
  cd $pkgname

  python setup.py install --root="$pkgdir" --prefix=/usr -O1

  install -Dm 644 "$pkgname.yml" "$pkgdir/etc/$pkgname.yml"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

